<?php
/**
 * Created by PhpStorm.
 * User: Yooke
 * Date: 2016/5/25
 * Time: 18:06
 */
namespace App\Http\Controllers;

use App\Interfaces\CartService;

use App\Interfaces\GoodsService;

use App\User;
use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;


use Session,Log;

class GoodsController extends Controller
{

    /**
     * @param $id
     * @param Request $request
     * @param GoodsService $goodsService
     * @param CartService $cartService
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     * 商品详情
     */
    public function index( $id,Request $request,GoodsService $goodsService,CartService $cartService){
        //dd($id);
        $user = Auth::user();
        $goods = $goodsService->get($id);
        if(!$goods){
            return view('errors.mobile404',['error'=>'商品不存在']);
        }
        $cartNumber = $cartService->getCartNumber();
        return view('mobile.goods.index',compact('goods','cartNumber'));
    }
    public function all(Request $request,GoodsService $goodsService){
        $goods= $goodsService->all($request);
        $type=$request->type;
        return view('mobile.goods.all',compact('goods','type'));
    }

}
